﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Resto.CostControl.Core.Facade.SiteModule.DataTransferObject;
using Resto.CostControl.Core.Cache;
using Resto.CostControl.Core.Domain.Model;
using Resto.CostControl.Common.Utility;

namespace Resto.CostControl.Core.Facade.DishOrderModule.DataTransferObject
{
    /// <summary>
    /// 每周菜肴订单
    /// </summary>
    [Serializable]
    public class WeekDishOrderDTO
    {
        #region 构造函数

        public WeekDishOrderDTO() { }

        public WeekDishOrderDTO(WeekDishOrder weekOrder) 
        {
            this.ID = weekOrder.ID;
            this.BeginDate = weekOrder.BeginDate;
            this.EndDate = weekOrder.EndDate;
            this.SiteId = weekOrder.SiteID;
        }

        #endregion

        #region 基本属性

        public string ID { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        public DateTime BeginDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime EndDate { get; set; }

        /// <summary>
        /// 项目点Id
        /// </summary>
        public string SiteId { get; set; }

        /// <summary>
        /// 项目点名称
        /// </summary>
        public string SiteName
        {
            get
            {
                SiteDTO siteDTO = SiteDTOCache.Get(SiteId);
                if (siteDTO != null)
                    return siteDTO.Name;
                else
                    return string.Empty;
            }
        }

        #endregion

        #region 公共方法

        public WeekDishOrder ToWeekDishOrder()
        {
            WeekDishOrder order = new WeekDishOrder()
            {
                BeginDate = TimeHelper.GetMinDateTime(this.BeginDate),
                EndDate = TimeHelper.GetMaxDateTime(this.EndDate),
                SiteID = this.SiteId,
            };

            return order;
        }

        #endregion
    }
}
